package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/queryById")
    public User queryById(int id){
        return userService.queryById(id);
    }

    @DeleteMapping("/delete")
    public Boolean deletUserById(int id){
        userService.deleteUserById(id);
        return true;
    }


    @PostMapping("/saveOrUpdateUser")
    public User saveOrUpdateUser(User user){

        return userService.save(user);
    }
}
